import {myRequest} from './request.js'
// 用户登录
export function userLogin(phone,password){
	return myRequest({
		url:'login/cellphone',
		data:{
			phone:phone,
			password:password
		}
	})
}

// 获取用户详情
export function getUserInfo(uid,cookie){
	return myRequest({
		url:'user/detail',
		data:{
			uid:uid,
			cookie:cookie
		}
	})
}

// 获取登陆后的信息
export function getLogedInfo(){
	return myRequest({
		url:'user/subcount'
	})
}

// 刷新登录状态
export function loginRef(cookie){
	return myRequest({
		url:'login/refresh',
		data:{
			cookie:cookie
		}
	})
}

//获取登录状态
export function getUserSta(cookie){
	return myRequest({
		url:'login/status',
		data:{
			cookie:cookie
		}
	})
}

// 退出登录
export function userLogout(){
	return myRequest({
		url:'logout'
	})
}

// 获取用户动态
export function getUserAc(id,cookie){
	return myRequest({
		url:'user/event',
		data:{
			uid:id,
			cookie
		}
	})
}

export class User {
	constructor(user,profile) {
		this.nickname = profile.nickname
		this.avatarUrl = profile.avatarUrl
	    this.backgroundUrl = profile.backgroundUrl
		this.province = profile.province
		this.city = profile.city
		this.createDays = user.createDays
		this.createTime = profile.createTime
		this.follows = profile.follows
		this.followeds = profile.followeds
		this.level = user.level
		this.listenSongs = user.listenSongs
		 
	}
}